﻿using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Joy.Erp.BasicArchives.Core.Filters;

namespace Joy.Erp.BasicArchives.Sales
{
    [RemoteService(Name = BasicArchivesRemoteServiceConsts.RemoteServiceName)]
    [Area(BasicArchivesRemoteServiceConsts.ModuleName)]
    [ControllerName("SaleOrder")]
    [Route("api/basic-archives/sale-order")]
    public partial class SaleOrderController : BasicArchivesController, ISaleOrderAppService
    {
        protected ISaleOrderAppService SaleOrderAppService => LazyServiceProvider.LazyGetRequiredService<ISaleOrderAppService>();

        [HttpGet]
        [Route("{id}")]
        public Task<SaleOrderDto> GetAsync(Guid id)
        {
            return SaleOrderAppService.GetAsync(id);
        }

        [HttpGet]
        [Route("child/{id}")]
        public Task<SaleOrderLineDto> GetChildAsync(Guid id)
        {
            return SaleOrderAppService.GetChildAsync(id);
        }

        [HttpGet]
        [Route("find")]
        public Task<SaleOrderDto> FindAsync(string filter)
        {
            return SaleOrderAppService.FindAsync(filter);
        }

        [HttpGet]
        [Route("find-by-source-key")]
        public Task<SaleOrderDto> FindBySourceKeyAsync(string sourceKey, string sourceType)
        {
            return SaleOrderAppService.FindBySourceKeyAsync(sourceKey, sourceType);
        }

        [HttpGet]
        public Task<PagedResultDto<SaleOrderDto>> GetListAsync(FilterRequestDto input)
        {
            return SaleOrderAppService.GetListAsync(input);
        }

        [HttpPost]
        [Route("query")]
        public Task<PagedResultDto<SaleOrderDto>> QueryAsync(FilterGroupRequestDto input)
        {
            return SaleOrderAppService.QueryAsync(input);
        }

        [HttpPost]
        [Route("query-children")]
        public Task<PagedResultDto<SaleOrderLineDto>> QueryChildrenAsync(FilterGroupRequestDto input)
        {
            return SaleOrderAppService.QueryChildrenAsync(input);
        }

        [HttpPost]
        public Task<SaleOrderDto> CreateAsync(SaleOrderCreateDto input)
        {
            return SaleOrderAppService.CreateAsync(input);
        }

        [HttpPut]
        [Route("{id}")]
        public Task<SaleOrderDto> UpdateAsync(Guid id, SaleOrderUpdateDto input)
        {
            return SaleOrderAppService.UpdateAsync(id, input);
        }

        [HttpPost]
        [Route("submit")]
        public Task<SaleOrderDto> SubmitAsync(Guid id)
        {
            return SaleOrderAppService.SubmitAsync(id);
        }

        [HttpPost]
        [Route("approve")]
        public Task<SaleOrderDto> ApproveAsync(Guid id)
        {
            return SaleOrderAppService.ApproveAsync(id);
        }

        [HttpPost]
        [Route("unapprove")]
        public Task<SaleOrderDto> UnApproveAsync(Guid id)
        {
            return SaleOrderAppService.UnApproveAsync(id);
        }

        [HttpDelete]
        [Route("{id}")]
        public Task DeleteAsync(Guid id)
        {
            return SaleOrderAppService.DeleteAsync(id);
        }

        [HttpPost]
        [Route("batch-create")]
        public Task<List<SaleOrderDto>> BatchCreateAsync(List<SaleOrderCreateDto> inputs, bool useBulk = false)
        {
            return SaleOrderAppService.BatchCreateAsync(inputs, useBulk);
        }

        [HttpPut]
        [Route("batch-update")]
        public Task<List<SaleOrderDto>> BatchUpdateAsync(List<SaleOrderBatchUpdateDto> inputs, bool useBulk = false)
        {
            return SaleOrderAppService.BatchUpdateAsync(inputs, useBulk);
        }

        [HttpPost]
        [Route("batch-delete")]
        public Task BatchDeleteAsync(List<Guid> ids, bool useBulk = false)
        {
            return SaleOrderAppService.BatchDeleteAsync(ids, useBulk);
        }
    }
}